package com.ruibang.glass.quality.controller.manage;

import com.ruibang.glass.common.domain.quality.BcStationHqDetail;
import com.ruibang.glass.common.domain.quality.GlassBindTest;
import com.ruibang.glass.quality.service.GlassStationService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-03-13  17:21
 * @Description: TODO
 * @Version: 1.0
 */


@RestController
@RequestMapping("/api/quality/manage/glassStation")
@Api(value = "半成品玻璃控制器(横切时间)", tags = {"半成品玻璃控制器(横切时间)"})
public class GlassStationController {

    @Autowired
    private GlassStationService glassStationService;

    @PostMapping("/batchColdGlassIdGetHqTime")
    @ApiOperation(value = "批量冷端玻璃ID获取横切时间", notes = "批量获取横切时间")
    public ResultBody<Map<String, LocalDateTime>> getColdGlassIdMappingStationStartTime(@RequestBody List<String> newGlassIds) {
        return ResultBody.success(glassStationService.getColdGlassIdMappingStationStartTime(newGlassIds));
    }

    @PostMapping("/batchHotGlassIdGetHqTime")
    @ApiOperation(value = "批量热端ID获取横切时间", notes = "批量获取横切时间")
    public ResultBody<Map<String, LocalDateTime>> getHotGlassIdMappingStationStartTime(@RequestBody List<String> hotIds) {
        return ResultBody.success(glassStationService.getHotGlassIdMappingStationStartTime(hotIds));
    }

    @PostMapping("/getColdGlassId")
    @ApiOperation(value = "根据热端玻璃ID获取冷端玻璃ID", notes = "根据热端玻璃ID获取冷端玻璃ID")
    public ResultBody<List<String>> getColdGlassId(@RequestBody List<String> hotIds) {
        return ResultBody.success(glassStationService.getColdGlassId(hotIds));
    }

    @GetMapping("/getHotId/{coldGlassId}")
    @ApiOperation(value = "根据冷端玻璃ID获取热端玻璃ID", notes = "根据冷端玻璃ID获取热端玻璃ID")
    public ResultBody<String> getHotId(@PathVariable String coldGlassId) {
        return ResultBody.success(glassStationService.getHotGlassId(coldGlassId));
    }

    @PostMapping("/getColdIdMappingHotId")
    @ApiOperation(value = "根据冷端玻璃ID获取热端玻璃ID映射关系", notes = "根据冷端玻璃ID获取热端玻璃ID映射关系")
    public ResultBody<Map<String, String>> getColdIdMappingHotId(@RequestBody List<String> coldIds) {
        return ResultBody.success(glassStationService.getColdIdMappingHotId(coldIds));
    }

    @PostMapping("/addHqInfoCache")
    @ApiOperation(value = "新增横切信息缓存", notes = "新增横切信息缓存")
    public ResultBody addHqInfoCache(@RequestBody BcStationHqDetail bcStationHqDetail) {
        glassStationService.addHqInfoCache(bcStationHqDetail);
        return ResultBody.success();
    }

    @PostMapping("/addGlassBindTestCache")
    @ApiOperation(value = "新增玻璃绑定缓存信息", notes = "新增玻璃绑定缓存信息")
    public ResultBody addGlassBindTestCache(@RequestBody GlassBindTest glassBindTest) {
        glassStationService.addGlassBindTestCache(glassBindTest);
        return ResultBody.success();
    }

}
